package com.wzm.utils.lmdb;

public class LMDBExample {
    public static void main(String[] args) {
        // Open the LMDB environment
//        try (Env<ByteBuffer> env = Env.create()
//                .setMaxDbs(1)
//                .open(new File("/Users/zhaolixue/chj/db/lmdb"))) {
//
//            // Open a database handle within the environment
//            try (Dbi<ByteBuffer> db = env.openDbi(DbiFlags.MDB_CREATE, "mydb")) {
//
//                // Put a key-value pair into the database
//                try (Txn<ByteBuffer> txn = env.txnWrite()) {
//                    db.put(txn, stringToBuffer("key"), stringToBuffer("value"));
//                    txn.commit();
//                }
//
//                // Lookup a value by key
//                try (Txn<ByteBuffer> txn = env.txnRead()) {
//                    ByteBuffer value = db.get(txn, stringToBuffer("key"));
//                    System.out.println(bufferToString(value));
//                }
//            }
//        }
//    }
//
//    // Utility method to convert a Java String to a ByteBuffer
//    private static ByteBuffer stringToBuffer(String s) {
//        return ByteBuffer.wrap(s.getBytes());
//    }
//
//    // Utility method to convert a ByteBuffer to a Java String
//    private static String bufferToString(ByteBuffer buffer) {
//        byte[] bytes = new byte[buffer.remaining()];
//        buffer.get(bytes);
//        return new String(bytes);
//    }
        String p = "/Users/zhaolixue/chj/db/lmdb/";
        String t = "/Users/zhaolixue/Downloads/db/topic/database";
        LmdbTest lmdbConfig = new LmdbTest(p);
//        lmdbConfig.lmdbInit();
//        lmdbConfig.putValueToDb("test1.lmdb","test","123");
//        lmdbConfig.putValueToDb("test1.lmdb","test1","1231");
        lmdbConfig.getAllValueByDbName("data.mdb");
        lmdbConfig.getValueByKey("topic-d94525ada1f000000-CarCenterTripData-v1.lmdb","");
//        Map<String,String> map = new HashMap<>();

    }
}
